/**
 * app's entry file
 * This app's name is Demo
 */
Ext.ns('Demo.page');
var Demo = {
    debug: true,
    launch: function () {
        Ext.onReady(this.init, this);
        Ext.USE_NATIVE_JSON = true;
    },
    init: function () {
        Ext.get('app-loading').remove();
        this.viewport = new Viewport();
        Ext.QuickTips.init();
    },
    log: function () {
        if (this.debug && typeof console !== 'undefined') {
            for (var i = 0; i < arguments.length; i++) {
                console.log(arguments[i]);
            }
            console.log('-------------------分割线-------------------');
        }
    },
    /**
     * mask body 的便捷方法
     *
     * @param {String} [message] loading信息
     */
    maskBody: function (message) {
        if (this.bodyMask) {
            return;
        }
        message = message || '加载中';
        var mask = new Ext.LoadMask(Ext.getBody(), {
            msg: message,
            removeMask: true
        });
        mask.show();
        this.bodyMask = mask;
        return mask;
    },
    removeMask: function () {
        if (this.bodyMask) {
            this.bodyMask.hide();
            delete this.bodyMask;
        }
    }
};
/**
 * @namespace
 */
Demo.url = {
    /**
     * 截取url中?或者#后面的字符串，并decode成object
     * @param {String} url
     * @param {String} [separator]
     * @return {Object}
     */
    parseParams: function (url, separator) {
        separator = separator || '#';
        return Ext.urlDecode(url.substr(url.indexOf(separator) + 1));
    }
};
Demo.launch();
